package com.gitee.hermer.engine.jars.core.event.storage.impl;

import java.util.LinkedHashMap;
import java.util.Map;

import com.gitee.hermer.boot.jee.commons.verify.Assert;
import com.gitee.hermer.engine.jars.core.event.EngineHandleEvent;
import com.gitee.hermer.engine.jars.core.event.EventStorage;
import com.gitee.hermer.engine.jars.core.event.storage.IEngineHandleEventStorage;

public class EngineHandleEventStorageImpl<E extends EngineHandleEvent> implements IEngineHandleEventStorage<E>{
	
	private Map<String, EventStorage<E>> storages = new LinkedHashMap<String, EventStorage<E>>();

	@Override
	public void beginEvent(E event) {
		Assert.notNull(event);
		storages.put(event.getID(), new EventStorage<E>(event));
	}

	@Override
	public boolean containsEvent(E event) {
		Assert.notNull(event);
		return storages.containsKey(event.getID());
	}
	@Override
	public void endEvent(E event) {
		Assert.notNull(event);
		storages.remove(event.getID());
	}

	

}
